package com.sxbbc.plat.controller.banks;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.sxbbc.bank.service.*;
import com.sxbbc.common.basics.rest.RestFactory;
import com.sxbbc.common.basics.rest.RestResponse;
import com.sxbbc.common.basics.utils.statics.StaticUtils;
import com.sxbbc.common.core.entity.banks.BankLoan;
import com.sxbbc.common.core.entity.banks.BankLoanApplyRecord;
import com.sxbbc.common.core.entity.banks.BankMultiInformation;
import com.sxbbc.common.core.entity.jz.ActivitySeckill;
import com.sxbbc.common.core.entity.jz.ChickenBonusConfigure;
import com.sxbbc.common.core.utils.BasePage;
import com.sxbbc.plat.common.ChickenMapping;
import freemarker.template.utility.StringUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;


/**
 * 贷款预约申请
 */

@Controller
public class BankLoanApplyRecordController {

    @Autowired
    private IBankLoanApplyRecordService iBankLoanApplyRecordService;


    @Autowired
    private IBankLoanService iBankLoanService;


    @Autowired
    private IBankMultiInformationService iBankMultiInformationService;


    @Autowired
    private IBankLoanApplyTrackService iBankLoanApplyTrackService;

    @RequestMapping(value = "/bankloanapplyrecord/list")
    public ModelAndView list() {
        ModelAndView view = new ModelAndView("/banks/bankloanapplyrecord/index");
        List<BankLoan> loanList=iBankLoanService.list();
        view.addObject("loadData",loanList);
        return view;
    }

    /**
     * 数据集
     * @param page
     * @param bankLoanApplyRecord
     * @param yyTime
     * @return
     */
    @RequestMapping(value ="/bankloanapplyrecord/listDate")
    @ResponseBody
    public RestResponse selectChickenBonusDay(BasePage<BankLoanApplyRecord> page, BankLoanApplyRecord bankLoanApplyRecord,String yyTime) {
       return iBankLoanApplyRecordService.listDate(page,bankLoanApplyRecord,yyTime);
    }

    /**
     * 根据id查询详情
     * @param id
     * @return
     */
    @RequestMapping(value = "/bankloanapplyrecord/detail")
    public  ModelAndView detail(String id){
        ModelAndView view = new ModelAndView("/banks/bankloanapplyrecord/details");
        BankLoanApplyRecord bankLoanApplyRecord=iBankLoanApplyRecordService.getById(id);
        List<BankMultiInformation> bankMultiInformations=iBankMultiInformationService.listByLoanApplRecordId(Integer.valueOf(id));
        view.addObject("data",bankLoanApplyRecord);
        view.addObject("bankInfo",bankMultiInformations);
        view.addObject("nowManager","张三丰");
        return view;
    }


    /**
     * 修改审核结果1、成功，2、失败，3、受理中
     * @param id
     * @param status
     * @return
     */
    @RequestMapping(value ="/bankloanapplyrecord/updateHandResult")
    @ResponseBody
    public RestResponse updateHandResult(Integer id,Integer status) {
        int n=iBankLoanApplyRecordService.updateHandleResult(id,status);
        return  new RestResponse("200","成功",null);
    }


}
